package com.gemptc.yueban.daoImp;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.gemptc.daoimp.SelectImp;
import com.gemptc.utils.DBUtil;
import com.gemptc.yueban.dao.IInsertActivity;

public class InsertActivityImp implements IInsertActivity {
	Connection connection = DBUtil.getConnection();
	PreparedStatement preparedStatement = null;
	ResultSet resultSet=null;
	@Override
	public boolean InsertActivity(int user_id, String ac_contact,
			int ac_number, String ac_title, String ac_time, String ac_lastTime,
			String ac_venue, String ac_venue_longitude,
			String ac_venue_latitude, String ac_destination,
			String ac_destination_longitude, String ac_destination_latitude,
			String ac_content, String ac_pic_path, String ac_date) {
		boolean b = false;
		String sql = "insert into activity(user_id,ac_contact,ac_number,ac_title,ac_time,ac_lastTime,"
				+ "ac_venue,ac_venue_longitude,ac_venue_latitude,"
				+ "ac_destination,ac_destination_longitude,ac_destination_latitude,"
				+ "ac_content,ac_pic_path,ac_date) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
		try {
			preparedStatement = connection.prepareStatement(sql);
			preparedStatement.setInt(1, user_id);
			preparedStatement.setString(2, ac_contact);
			preparedStatement.setInt(3, ac_number);
			preparedStatement.setString(4, ac_title);
			preparedStatement.setString(5, ac_time);
			preparedStatement.setString(6, ac_lastTime);
			preparedStatement.setString(7, ac_venue);
			preparedStatement.setString(8, ac_venue_longitude);
			preparedStatement.setString(9, ac_venue_latitude);
			preparedStatement.setString(10, ac_destination);
			preparedStatement.setString(11, ac_destination_longitude);
			preparedStatement.setString(12, ac_destination_latitude);
			preparedStatement.setString(13, ac_content);
			preparedStatement.setString(14, ac_pic_path);
			preparedStatement.setString(15, ac_date);
			preparedStatement.execute();
			b = true;
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			DBUtil.release(resultSet, preparedStatement, connection);
		}
		return b;
	}
}
